Page({
    data:{
        tempFilePaths:[],
        fileimgid:"",
        fileList:[
            {url:'http://tmp/wx6de01012001c5575.o6zAJs2V6pCdDfVtq4AlYX_BvVqM.YFAjXGu8vapd180f66e17b2a9a810d18a09358b27d5b.png'},
            {url:'http://tmp/wx6de01012001c5575.o6zAJs2V6pCdDfVtq4AlYX_BvVqM.IBFKNR9AbOfk33d4df95c5ae8db5fe038e2d427ad71f.png'}
        ]
        
    },
    upimg(){
        wx.chooseImage({
            count: 1,
            sizeType: ['original','compressed'],
            sourceType: ['album','camera'],
            success: (res)=>{
                console.log(res);
                const tempFilePaths =res.tempFilePaths;
                this.setData({
          
                    //需要将依次上传的图片数组拼接 chooseimg: 
                    tempFilePaths:[...this.data.tempFilePaths,...res.tempFilePaths]
                  })
                wx.cloud.uploadFile({
                    cloudPath:'yu.png',
                    filePath:tempFilePaths[0],
                    success:res=>{
                        console.log(res);
                        const fileimgid=res.fileID;
                        console.log(fileimgid);
                        this.setData({
                            fileimgid
                        })
                    },
                    fail: console.error
                })
            },
            fail: ()=>{},
            complete: ()=>{}
        });
    },
    downimg(){
        wx.cloud.downloadFile({
            fileID: this.data.fileimgid, // 文件 ID
            success: res => {
              // 返回临时文件路径
              console.log(res.tempFilePath)
                wx.saveImageToPhotosAlbum({
                  filePath: res.tempFilePath,
                  success: (result)=>{
                      console.log(res.tempFilePath)
                  },
                  fail: ()=>{},
                  complete: ()=>{}
              });
            },
            fail: console.error
          })          
    },
    yuimg(){
        this.setData({
            fileList:[
                {url:'http://tmp/wx6de01012001c5575.o6zAJs2V6pCdDfVtq4AlYX_BvVqM.YFAjXGu8vapd180f66e17b2a9a810d18a09358b27d5b.png'},
                {url:'cloud://yun1-7glegjwn33768ff6.7975-yun1-7glegjwn33768ff6-1305144331/1616494389531.png'}
            ]
        })
    },
    onLoad(){
        this.setData({
            fileList:[
                {url:'cloud://yun1-7glegjwn33768ff6.7975-yun1-7glegjwn33768ff6-1305144331/1616494389531.png'},
                {url:'http://tmp/wx6de01012001c5575.o6zAJs2V6pCdDfVtq4AlYX_BvVqM.IBFKNR9AbOfk33d4df95c5ae8db5fe038e2d427ad71f.png'}
            ]
        })
        this.yuimg();
    }
})